<?php
require('funciones.php');
switch($sec){
	//SECCION ARTICULOS ------------------------->>>>>>>>>>>>
	case "art":
		?>
		<table border="0" cellpadding="0" cellspacing="0">
		<tbody>
			<tr>
				<th width="150px;"><h3>Fecha</h3></th>
				<th><h3>T&iacute;tulo</h3></th>
				<th width="80px;"><h3>Hits</h3></th>
				<th width="80px;"><small><h3>Comentarios</h3></small></th>
				<th width="80px;"><h3>Publicado</h3></th>
				<th width="80px;"><h3>Comentar</h3></th>
				<th colspan="2"><h3>Acciones</h3></th>
			</tr>
	<?php
			$result = mysql_query("SELECT * FROM articulos ORDER BY fecha_creacion DESC LIMIT 15", $con);
			while ($row = mysql_fetch_array($result)){
			echo "	<tr>
						<!--<td>".$row['id']."</td>-->
						<td>".$row['fecha_creacion']."</td>
						<td><a href=\"../articulos/".$row['titulo_enlace']."/\" target=\"_blank\">".$row['titulo']."</a></td>
						<td>".$row['lecturas']."</td>
						<td>".$row['comentarios']."</td>";
			
						if($row['activo']=="D"){
							echo "<td style=\"text-align:center;\"><span id=\"boxart_".$row['id']."\"><a title=\"Activar articulo\" onclick=\"activarArticulo(".$row['id'].")\"><img src=\"img/cancel.png\" alt=\"Activo\" /></a></span></td>";
						}else{
							echo "<td style=\"text-align:center;\"><span id=\"boxart_".$row['id']."\"><a title=\"Desactivar articulo\" onclick=\"activarArticulo(".$row['id'].")\"><img src=\"img/accept.png\" alt=\"Desactivado\" /></a></span></td>";
						}
						
						if($row['actcom']=="D"){
							echo "<td style=\"text-align:center;\"><span id=\"boxcom_".$row['id']."\"><a title=\"Permitir comentarios\" onclick=\"permitirComentario(".$row['id'].",'art',0)\"><img src=\"img/cancel.png\" alt=\"Activo\" /></a></span></td>";
						}else{
							echo "<td style=\"text-align:center;\"><span id=\"boxcom_".$row['id']."\"><a title=\"No permitir comentarios\" onclick=\"permitirComentario(".$row['id'].",'art',0)\"><img src=\"img/accept.png\" alt=\"Desactivado\" /></a></span></td>";
						}
						
						echo "<td width='40px;'><a href='../admin/index.php?pag=art&amp;opc=edt&amp;id=".$row['id']."'>Editar</a></td>
						<td width='40px;'><a onclick=\"eliminarDato(".$row['id'].",'art',0)\">Borrar</a></td>\n
					</tr>";
			}
	?>
		</tbody>
		</table>
	<?php
	break;
	//SECCION COMENTARIOS ------------------------->>>>>>>>>>>>
	case "com":
		?>
		<table border="0" cellpadding="0" cellspacing="0">
		<tbody>
			<tr>
				<td><h3>ID</h3></td>
				<td><h3>Fecha</h3></td>
				<td><h3>Art&iacute;culo</h3></td>
				<td><h3>Nombre</h3></td>
				<td></td>
				<td></td>
			</tr>
	<?php
			$result = mysql_query("SELECT * FROM comentarios ORDER BY fecha DESC LIMIT 10", $con);
			while ($row = mysql_fetch_array($result)){
			echo "	<tr>
						<td>".$row['id']."</td>
						<td>".$row['fecha']."</td>
						<td>".$row['articulo_id']."</td>
						<td>".$row['nombre']."</td>
						<td rowspan='2'><a href='../admin/index.php?pag=com&amp;opc=edt&amp;id=".$row['id']."'>Modificar</a></td>
						<td rowspan='2'><a onclick=\"eliminarDato(".$row['id'].",'com',".$row['articulo_id'].")\">Eliminar</a></td>\n
					</tr>";
			echo "	<tr>
						<td colspan='4'>".$row['contenido']."</td>
					
					</tr>";
			}
	?>
		</tbody>
		</table>
	<?php
	break;
	//SECCION EJEMPLOS ------------------------->>>>>>>>>>>>
	case "eje":
		?>
		<table border="0" cellpadding="0" cellspacing="0">
		<tbody>
			<tr>
				<td><h3>ID</h3></td>
				<td><h3>Fecha</h3></td>
				<td><h3>T&iacute;tulo</h3></td>
				<td><h3>Autor</h3></td>
				<td></td>
				<td></td>
			</tr>
	<?php
			$result = mysql_query("SELECT * FROM ejemplos ORDER BY fecha DESC", $con);
			while ($row = mysql_fetch_array($result)){
			echo "	<tr>
						<td>".$row['id']."</td>
						<td>".$row['fecha']."</td>
						<td>".$row['titulo']."</td>
						<td>".$row['autor']."</td>
						<td><a href='../admin/index.php?pag=eje&amp;opc=edt&amp;id=".$row['id']."'>Modificar</a></td>
						<td><a onclick=\"eliminarDato(".$row['idejemplo'].",'eje',0)\">Eliminar</a></td>\n
					</tr>";
			}
	?>
		</tbody>
		</table>
	<?php
	break;
	//SECCION ENCUESTAS ------------------------->>>>>>>>>>>>
	case "enc":
		?>
		<table border="0" cellpadding="0" cellspacing="0">
		<tbody>
			<tr>
				<td><h3>ID</h3></td>
				<td><h3>Fecha</h3></td>
				<td><h3>Pregunta</h3></td>
				<td><h3>Nro. Votos</h3></td>
				<td></td>
				<td></td>
			</tr>
	<?php
			$result = mysql_query("SELECT * FROM encuesta ORDER BY fecha DESC LIMIT 10", $con);
			while ($row = mysql_fetch_array($result)){
			echo "	<tr>
						<td>".$row['idenc']."</td>
						<td>".$row['fecha']."</td>
						<td>".$row['pregunta']."</td>
						<td>".$row['nrovotos']."</td>
						<td><a href='../admin/?pag=enc&amp;opc=edt&amp;id=".$row['idenc']."'>Modificar</a></td>
						<td><a onclick=\"eliminarDato(".$row['idenc'].",'enc',0)\">Eliminar</a></td>\n
					</tr>";
			}
	?>
		</tbody>
		</table>
	<?php
	break;
	//SECCION USUARIOS ------------------------->>>>>>>>>>>>
	case "usu":
		?>
		<table border="0" cellpadding="0" cellspacing="0">
		<tbody>
			<tr>
				<td><h3>ID</h3></td>
				<td><h3>Fecha</h3></td>
				<td><h3>NickName</h3></td>
				<td><h3>E-mail</h3></td>
				<td><h3>Web/Blog</h3></td>
				<td><h3>Activo</h3></td>
				<td></td>
				<td></td>
			</tr>
	<?php
			$result = mysql_query("SELECT * FROM usuario ORDER BY fecha DESC LIMIT 10", $con);
			while ($row = mysql_fetch_array($result)){
			echo "	<tr>
						<td>".$row['id']."</td>
						<td>".$row['fecha']."</td>
						<td>".$row['nick']."</td>
						<td>".$row['email']."</td>
						<td>".$row['web']."</td>
						<td>".$row['activo']."</td>
						<td><a href='../admin/?pag=usu&amp;opc=edt&amp;id=".$row['id']."'>Modificar</a></td>
						<td><a onclick=\"eliminarDato(".$row['id'].",'usu',0)\">Eliminar</a></td>\n
					</tr>";
			}
	?>
		</tbody>
		</table>
	<?php
	break;
	//SECCION CATEGORIAS ------------------------->>>>>>>>>>>>
	case "cat":
		?>
		<table border="0" cellpadding="0" cellspacing="0">
		<tbody>
			<tr>
				<th><h3>ID</h3></th>
				<th><h3>Nombre Categoria</h3></th>
				<th><h3>Descripcion</h3></th>
				<th colspan="3"><h3>Acciones</h3></th>
			</tr>
	<?php
			/*$result = mysql_query("SELECT * FROM categorias ORDER BY nombre", $con);
			while ($row = mysql_fetch_array($result)){
			echo "	<tr>
						<td>".$row['id']."</td>
						<td>".$row['nombre']."</td>
						<td>".$row['descripcion']."</td>
						<td><a href='../admin/?pag=cat&amp;opc=edt&amp;id=".$row['id']."'>Modificar</a></td>
						<td><a onclick=\"eliminarDato(".$row['id'].",'cat',0)\">Eliminar</a></td>\n
					</tr>";
			}*/
			listar_categorias(0);
	?>
		</tbody>
		</table>
	<?php
	break;
	//SECCION REFERENCIAS ------------------------->>>>>>>>>>>>
	case "ref":
		?>
		<table border="0" cellpadding="0" cellspacing="0">
		<tbody>
			<tr>
				<td><h3>ID</h3></td>
				<td><h3>Articulo</h3></td>
				<td><h3>Blog</h3></td>
				<td><h3>Titulo Articulo</h3></td>
				<td><h3>URL</h3></td>
				<td><h3>Fecha</h3></td>
				<td><h3>Estado</h3></td>
				<td></td>
				<td></td>
			</tr>
	<?php
			$result = mysql_query("SELECT * FROM trackback ORDER BY added DESC", $con);
			while ($row = mysql_fetch_array($result)){
			echo "	<tr>
						<td>".$row['id']."</td>
						<td>".$row['articulo_id']."</td>
						<td>".$row['blog_name']."</td>
						<td>".$row['title']."</td>
						<td>".$row['url']."</td>
						<td>".$row['added']."</td>
						<td>".$row['activo']."</td>
						<td><a href='../admin/?pag=cat&amp;opc=edt&amp;id=".$row['id']."'>Modificar</a></td>
						<td><a onclick=\"eliminarDato(".$row['id'].",'cat',0)\">Eliminar</a></td>\n
					</tr>";
			}
	?>
		</tbody>
		</table>
	<?php
	break;
	default:
	echo "NADA";
}
?>
